package ru.pb.game.network.engine.client.packets.sendable;

import org.apache.log4j.Logger;

import ru.pb.game.network.engine.client.packets.GameServerToClientPacket;
import ru.pb.game.objects.model.players.Player;
import ru.pb.game.objects.model.room.Room;

public class PROTOCOL_BATTLE_PRESTARTBATTLE_ACK extends GameServerToClientPacket
{
	private static final Logger _log = Logger.getLogger(PROTOCOL_BATTLE_PRESTARTBATTLE_ACK.class);
	private Player _player;
	private Room _room;

	private int _type;

	public PROTOCOL_BATTLE_PRESTARTBATTLE_ACK(Player player, int server_type)
	{
		_player = player;
		_room = _player.getRoom();
		_type = server_type;
	}

	/*
	 * 06:0f
	 * 01:00:00:00
	 * 02:00:00:00
	 * 03
	 * 5d:b2:e9:1d
	 * c2:74
	 * 5d:b2:e9:1d
	 * c2:74
	 * 00
	 * 4a:73:01:5d
	 * c2:74
	 * 0a:5d:58:3e
	 * c2:74
	 * 00
	 * 26:6a:56:16
	 * 44:9c
	 * 91:00:00:00
	 * 47:06:00:00
	 * 20:21:22:00:01:02:03:04:05:06:07:08:09:0a:0b:0c:0d:0e:0f:10:11:12:13:14:15:16:17:18:19:1a:1b:1c:1d:1e:1f
	 */
	@Override
	public void writeImpl()
	{

		writeH(3846);
		writeBoolD(_room.isInFight()); // battle exist
		writeD(_room.getLeader().getSlot()); // slot

		writeC(3); // тип сервера? 1 - p2p server - норм работает

		writeB(new byte[]{0x7f, 0x00,(byte) 0x00,(byte) 0x01}); // 
		writeH(29890);// порт откуда идет
		writeB(new byte[]{0x7f, 0x00,(byte) 0x00,(byte) 0x01}); // 
		writeH(29890);// порт куда идет
		writeC();

		writeB(new byte[]{0x7f, 0x00,(byte) 0x00,(byte) 0x01}); // 
		writeH(29890);// порт
		writeB(new byte[]{0x7f, 0x00,(byte) 0x00,(byte) 0x01}); // 
		writeH(29890); // порт
		writeC();

		writeB(new byte[]{0x7f, 0x00,(byte) 0x00,(byte) 0x01}); // Начиная от суда 4,2,4,4 байтов читается, потом в каком то случае 35 байт
		writeB(new byte[] {
			//
			// (byte) 0xc3, 0x51, 0x74, 0x36, // айпи чего?
			//
			0x43, (byte) 0x9c, // 40000 - порт?
			//
			(byte) 0x91, 0x00, 0x00, 0x00,
			//
			(byte) 0x47, 0x06, 0x00, 0x00});

		writeC();

		writeB(new byte[] {0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f});
	}
}